/**
 * 文件名称:  LoginAction.java
 * 所属版权:  Stone Technologies Co., Ltd. Copyright 2010-2021, All rights reserved
 * 简单描述:  <描述>
 * 修改作者:  xdli
 * 修改时间:  2012-6-13
 * 修改内容:  <修改内容>
 */
package com.chinastar.iweb.user.action;

import java.util.List;

import com.chinastar.iweb.common.struts.StarAction;
import com.chinastar.iweb.common.util.CommonTool;
import com.chinastar.iweb.common.util.Constuls;
import com.chinastar.iweb.user.domain.UserBean;
import com.chinastar.iweb.user.manager.UserManager;

/**
 * LoginAction
 *  
 * @author  xdli
 * @version 2012-6-13
 * @see     LoginAction
 * @since   1.0
 */
public class LoginAction extends StarAction
{
    
    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = -2733795752798631479L;
    
    private UserManager userManager = null;
    
    private UserBean userBean = new UserBean();

    /**
     * 用户登录
     * @return 
     */
    public String login()
    {
        UserBean bean = userManager.login(userBean);
        if (CommonTool.isEmpty(bean))
        {
            return ERROR;
        }
        getSession().setAttribute("userBean", bean);
        return SUCCESS;
    }
    
    /**
     * 查询所有用户列表
     * @return 
     */
    public String queryList()
    {
        List<UserBean> userList = userManager.queryList();
        getRequest().setAttribute("userList", userList);
        return SUCCESS;
    }
    
    /**
     * 数据全部删除
     * @return 
     */
    public String deleteAll()
    {
        boolean isDeleteAll = userManager.deleteAll();
        StringBuffer message = null;
        if (isDeleteAll)
        {
            message = new StringBuffer(Constuls.DELETE_SUCCESS);
        }
        else 
        {
            message = new StringBuffer(Constuls.DELETE_ERROR);
        }
        getRequest().setAttribute("message", message.toString());
        return SUCCESS;
    }
    
    public UserManager getUserManager()
    {
        return userManager;
    }

    public void setUserManager(UserManager userManager)
    {
        this.userManager = userManager;
    }

    public UserBean getUserBean()
    {
        return userBean;
    }

    public void setUserBean(UserBean userBean)
    {
        this.userBean = userBean;
    }
    
}
